#include <iostream>
#include <array>
#include <ctime>
using namespace std;

void maopaopaixu() {
    srand(static_cast<unsigned>(time(nullptr)));
    // array<int, 10> arr = {9,2,4,6,27,7,78,35,63,24};
    array<int, 10> arr = {};
    for (int i = 0; i < arr.size(); i++) {
        //填充的数组每个元素是一样的
        //std::array 的 fill 方法是一个成员函数，但它应该只被调用一次来填充整个数组，而不是在循环中每次迭代都调用。
        arr[i] = rand() % 1000;
        cout << arr[i] << "  ";
    }

    cout << "\n************************************"<<endl;
    for (int i = 0; i < arr.size(); i++) {
        cout << arr[i] << "  ";
    }

    for (int i = 0; i < arr.size() - 1; i++) {
        for (int j = 0; j < arr.size() - i - 1; j++) {
            if (arr[j] > arr[j + 1]) {
                int temp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = temp;
            }
        }
    }


    cout << "\t"<<endl;
    for (int i = 0; i < arr.size(); i++) {
        cout << arr[i] << "  ";
    }
}
